//
//  Kratos_BaseTableViewCell.m
//  kk_framework
//
//  Created by 7yao.top on 2018/11/5.
//  Copyright © 2018年 7yao.top. All rights reserved.
//

#import "Kratos_BaseTableViewCell.h"
#import "Kratos_TableViewControllerConst.h"
#import "Kratos_baseCellModel.h"
#import "UIView+kkk_viewExtionsion.h"

@implementation Kratos_BaseTableViewCell

//cell初始化方法
+ (Kratos_BaseTableViewCell *)Kratos_cellWithIdentifier:(NSString *)cellIdentifier Kratos_tableView:(UITableView *)tableView
{
    Kratos_BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell == nil){
        cell = [[Kratos_BaseTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self Kratos_setupUI];
        
    }
    return self;
}

//初始化UI方法
- (void)Kratos_setupUI
{
    CALayer *topLine = [CALayer layer];
    [topLine setFrame:CGRectMake(0, 0, self.frame.size.width, Kratos_KSeparateHeight)];
    [topLine setBackgroundColor:Kratos_KSeparateColor.CGColor];
    [self.contentView.layer addSublayer:topLine];
    self.topLine = topLine;
    
    CALayer *bottomLine = [CALayer layer];
    [bottomLine setFrame:CGRectMake(0, 0, self.frame.size.width, Kratos_KSeparateHeight)];
    [bottomLine setBackgroundColor:Kratos_KSeparateColor.CGColor];
    [self.contentView.layer addSublayer:bottomLine];
    self.bottomLine = bottomLine;
    
    
}
//设置数据源方法
- (void)Kratos_setupDataModel:(Kratos_baseCellModel *)model
{
    self.cellModel = model;
    self.selectionStyle  = model.Kra_selectionStyle;
    [self.bottomLine setKra_y:model.Kra_cellHeight - model.Kra_separateHeight];
    [self.bottomLine setKra_height:model.Kra_separateHeight];
    [self.topLine setKra_height:model.Kra_separateHeight];
    [self.bottomLine setBackgroundColor:model.Kra_separateColor.CGColor];
    [self.topLine setBackgroundColor:model.Kra_separateColor.CGColor];

}
- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.bottomLine setKra_width:self.frame.size.width];
    [self.topLine setKra_width:self.frame.size.width];
    
}
+ (CGFloat)Kratos_getCellHeight:(Kratos_baseCellModel *)model
{
    return model.Kra_cellHeight;
}




@end
